SetSymmetricDifference Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Computes the set-theoretic symmetric difference of two collections. The symmetric difference of two sets is all items that appear in the one of the sets, but not in the other. If an item appears X times in the one set, and Y times in the other set, the symmetric difference contains the item AbsoluteValue(X - Y) times. The source collections are not changed. A new collection is created with the symmetric difference of the collections; the order of the items in this collection is undefined.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static IEnumerable<T> SetSymmetricDifference<T>(
	IEnumerable<T> collection1,
	IEnumerable<T> collection2
)
Visual Basic (Declaration)
Public Shared Function SetSymmetricDifference(Of T) ( _
	collection1 As IEnumerable(Of T), _
	collection2 As IEnumerable(Of T) _
) As IEnumerable(Of T)
Visual C++
public:
generic<typename T>
static IEnumerable<T>^ SetSymmetricDifference (
	IEnumerable<T>^ collection1, 
	IEnumerable<T>^ collection2
)

Parameters

collection1
IEnumerable<(Of <T>)>
The first collection to symmetric difference.
collection2
IEnumerable<(Of <T>)>
The second collection to symmetric difference.

Return Value

The symmetric difference of collection1 and collection2, considered as sets.

Type Parameters

T

Remarks

When equal items appear in both collections, the returned collection will include an arbitrary choice of one of the two equal items.

The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals.

If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the SymmetricDifference or SymmetricDifferenceWith methods on that class.

Exceptions

ExceptionCondition
System..::ArgumentNullExceptioncollection1 or collection2 is null.

See Also